package com.china08.yxyapi.util;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

public class EsResourceUpdateUtil {

    private static final Logger LOGGER = LoggerFactory.getLogger(EsResourceUpdateUtil.class);

    private static final String ES_RES_RESOURCE_SINGLE_QUEUE = "es-res-resource-single-queue";

    public static void updateEsResoure(String resourceId) {
        LOGGER.info("发送的资源Id：" + resourceId);
        try {
            RabbitTemplate template = SpringContextUtil.getBean(RabbitTemplate.class);
            if (StringUtils.isNotBlank(resourceId)) {
                template.convertAndSend(ES_RES_RESOURCE_SINGLE_QUEUE, resourceId.trim());
            }
        } catch (Exception e) {
            LOGGER.error("发送资源id异常", e);
        }
        LOGGER.info("发送的资源Id结束");
    }

}
